ds_grid_read


描述

This function can be used to convert a string which has been created previously by the function ds_grid_write() back into a ds_grid. The ds_grid must have been created previously (see the example below). 请注意,如果数据结构是使用以前的版本创建的GameMaker你应该添加可选参数“legacy”,将其设置为true,因为此版本的字符串格式已更改。


语法:

ds_grid_read(index, string [, legacy]);

参数 描述
index The index of the grid to read.
string The string to read into the ds_grid.
legacy (optional) 可以是 truefalse 或完全省略。


返回:

N/A(无返回值)


例如:

grid = ds_grid_create(room_width div 32, room_height div 32);
ini_open("Save.ini");
ds_grid_read(grid, ini_read_string("Save", "0", ""));
ini_close()

The above code creates a ds_grid based on the size of the room (each 32x32 square of pixels represents one grid cell) and then reads a previously saved set of grid data from an ini file into the new ds grid.